import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:iea/screens/indexPage/index_page.dart';
import 'package:iea/screens/mineCoursePage/mineCourse_page.dart';
// import 'package:iea/screens/personalCenterPage/personalCenter_page.dart';
// import 'package:iea/screens/personalCenterPage/personalCenter_page.dart';
import 'package:iea/screens/paidCauserDetail/detail_picBar.dart';
// import 'package:flutter/rendering.dart';

// import 'screens/paidCauserDetail/detail_picBar.dart';
void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // debugPaintSizeEnabled = true;
    return MaterialApp(
      // showPerformanceOverlay: true,
      title: 'Material App',
      theme: ThemeData(
        primarySwatch: Colors.blue
      ),
      home:HomePage(title: 'iea'),
      routes: {
        '/PicBar': (context)=> PicBar(),
      },
    );
  }
}

class HomePage extends StatefulWidget {
  final String title;
  HomePage({Key key,this.title}) : super(key: key);
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int _currentIndex = 0;
  final widgetItems = [Index(), MineCoursePage()];
  List<String> widgetNames = ['首页', '我的课程'];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // 顶栏
      appBar: AppBar(
        title: Text(widgetNames[_currentIndex], style: TextStyle(color: Colors.black),),
        backgroundColor: Colors.white,
      ),
      // 主内容区
      // body: Center(
      //   child: widgetItems[_currentIndex],
      // ),
      body: IndexedStack(
        index: _currentIndex,
        children: widgetItems,
      ),
      // 底部导航
      bottomNavigationBar: BottomNavigationBar(
        items: [
          BottomNavigationBarItem(
            icon: _currentIndex == 0 ? Image.asset('assets/images/homepage/Page1Copy4@2x.png',width: 25,height: 25,):Image.asset('assets/images/homepage/Page1Copy6@2x.png',width: 25,height: 25,),
            title: Text('首页', style: TextStyle(color: Color(0xFF06244e), fontSize: 14), )
          ),

          BottomNavigationBarItem(
            icon: _currentIndex == 1 ? Image.asset('assets/images/homepage/Page1Copy2@2x.png',width: 25,height: 25,):Image.asset('assets/images/homepage/Page1@2x.png',width: 25,height: 25,) ,
            title: Text('我的课程', style: TextStyle(color: Color(0xFF06244e), fontSize: 14), )
          )
        ],
        currentIndex: _currentIndex,
        type: BottomNavigationBarType.fixed,
        onTap: _onItemTaped,
      ),
    );

  }
  void _onItemTaped (int index){
    // Navigator.pushNamed(context, '/test', arguments: 0);
    setState(() {
      _currentIndex = index;
    });
  }
}